<?php

namespace App\Http\Criteria;

use App\Repository\Criteria;
use App\Repository\Constracts\RepositoryInterface as Repository;

class OrderByCriteria extends Criteria {

    protected $column;
    private $orderBy;
    const DESC = 'desc';
    const ASC = 'asc';

    public function __construct($orderBy = 'desc')
    {
        $this->orderBy = $orderBy;
    }

    public function apply($model, Repository $repository)
    {
        return $model->orderBy($this->column, $this->orderBy);
    }
}
